<?php
namespace util;
class Dispatcher{
	private $request;
	public function __construct(Request $request){
		$this->request = $request;
	}

    public function handle(){
        $controllerDi = DiStore::getInstance()->getDi('ControllerDi');
        $controllerDi->setParameter('_W',$this->request->_W);
        $controllerDi->setParameter('_GPC',$this->request->_GPC);
        $controller = $controllerDi[$this->request->controller];
        $action = $this->request->action;

        if (empty($controller)){
            echo 'NOT FIND, 404';
            exit();
        }

        \call_user_func(array($controller,$action));
	}
}